import http = require('http')
import https = require('https')

interface options {
  url: string
  method: 'GET' | "POST" | "PUT" | "DELETE"
}

function httpAdapter(config) {
  const isHttps = /https:?/
  return isHttps.test(config.url) ? https : http
}


class Request {
  adapter
  constructor(options) {
    console.log(options);
    this.adapter = httpAdapter(options)
  }
  get(options) {
    console.log('get method');
  }
  post(options) {
    console.log('post method');
  }
}

function createInstance(config) {
  return new Request(config)
}

const request = createInstance({ url: 'https://baidu.com', method: 'GET' })
request.get({})
